package com.jh.fcsm.beans.area;

import com.alibaba.excel.annotation.ExcelProperty;
import com.jh.fcsm.common.validation.group.DefaultGroup;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.jh.fcsm.common.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.ibatis.type.JdbcType;
import tk.mybatis.mapper.annotation.ColumnType;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

/**
 * 行政区划管理对象 basic_area
 *
 * @author linq
 * @date 2024-08-15
 */
@Table(name = "basic_area")
@ApiModel(value = "com.jh.area.beans.area.BasicArea", description = "行政区划管理")

public class BasicArea extends BaseEntity {
    private static final long serialVersionUID = 1L;
    @NotBlank(message = "行政区划代码不能为空", groups = DefaultGroup.class)
    @Size(min = 6, max = 6, message = "行政区划代码长度必须为6", groups = DefaultGroup.class)
    @ExcelProperty(index = 1)
    @Column(name = "CODE")
    @ColumnType(jdbcType = JdbcType.VARCHAR)
    @ApiModelProperty(value = "行政区划代码")
    private String code;
    @NotBlank(message = "行政区划名称不能为空", groups = DefaultGroup.class)
    @Size(min = 2, max = 20, message = "行政区划名称长度必须为2~20个字符", groups = DefaultGroup.class)
    @ExcelProperty(index = 2)
    @Column(name = "NAME")
    @ColumnType(jdbcType = JdbcType.VARCHAR)
    @ApiModelProperty(value = "行政区划名称")
    private String name;
    @NotBlank(message = "父级区划代码不能为空", groups = DefaultGroup.class)
    @Pattern(regexp = "0|\\d{6}", message = "父级代码必须为“0”或6位数字", groups = DefaultGroup.class)
    @ExcelProperty(index = 3)
    @Column(name = "PARENT_CODE")
    @ColumnType(jdbcType = JdbcType.VARCHAR)
    @ApiModelProperty(value = "父级区划代码")
    private String parentCode;




    /**
     * SET 行政区划代码
     *
     * @param code
     */
    public void setCode(String code) {
        this.code = code == null ? null : code;
    }

    /**
     * GET 行政区划代码
     *
     * @return code
     */
    public String getCode() {
        return code;
    }

    /**
     * SET 行政区划名称
     *
     * @param name
     */
    public void setName(String name) {
        this.name = name == null ? null : name;
    }

    /**
     * GET 行政区划名称
     *
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * SET 父级区划代码
     *
     * @param parentCode
     */
    public void setParentCode(String parentCode) {
        this.parentCode = parentCode == null ? null : parentCode;
    }

    /**
     * GET 父级区划代码
     *
     * @return parentCode
     */
    public String getParentCode() {
        return parentCode;
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    }


}
